package VN.EDU.IMIC.DEVELOPER.DOTHANHTUNG.ARRAYBAI9;

public class Model {
	public double[] totalHour(double[][] employee){
		double[] result = new double[employee.length];
		
		for (int emp = 0; emp < employee.length;emp++){
			double total=0;
				for (int hour = 0; hour < employee[emp].length; hour++){
					total += employee[emp][hour];
				}
				result[emp] = total;
			}
		return sort(result);
		//return result;
		 
	}
	
	public double[] sort(double[] result){
		int i,j,max,temp;
		for (i = 0;i < result.length;i++){
			max = i;
			for (j = i+1; j < result.length;j++){
				if(result[max] < result[j]) {
					max = j;
				}
			}
				temp = (int) result[max];
				result[max] = result[i];
				result[i] = temp;
			
		}
		return result;
		
		/***int i,j,first,temp;
		for (i = result.length-1;i >0;i--){
			first = 0;
			for (j=1;j<=i;j++){
				if(result[j]<result[first]){
					first = j;
				}
			}
			temp = (int) result[first];
			result[first] = result[i];
			result[i]=temp;
		}
		return result;***/
	}
	
}
